package com.bigchui.DesignPattern.Singleton.seriable;

import java.io.Serializable;

/**
 * 防止序列化破坏单例
 * Created by wangzhen on 2019/3/10.
 */
public class SeriableSingleton implements Serializable {
    private SeriableSingleton(){

    }
    private static final SeriableSingleton instance=new SeriableSingleton();
    public static SeriableSingleton getInstance(){
        return instance;
    }
    //重写这个函数即可防止序列化破坏单例
    private Object readResolve(){
        return instance;
    }
}
